<script type="text/javascript">
	function doSearchDeployments(value) {
		
	}
	
	//表格查询  
	function reloadDeployments() {
		var params = deployments_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		deployments_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		deployments_list.datagrid('unselectAll');
		deployments_list.datagrid('uncheckAll');
	}


	function addDeployments() {
		createFromWindow("新增信息", "processdef.do?editDeployments", "processdef.do?saveDeployments",
				function(data) {
					reloadDeployments();
				});
	}
	
	function deleteDeployments() {
		var rows = deployments_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('processdef.do?deleteDeploymentsItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadDeployments();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function showSourceDeployments() {
		var rows = deployments_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("查看资源", "processdef.do?showSourceDeployments&deploymentId=" + rows[0].id,
					null, function(data) {
						reloadDeployments();
					},false);
		} else {
			showMsg('请选择操作记录.');
		}

	}
	function clearDeploymentsSearch() {
		setGridSearchParams('deployments_list','deploymentsSearchForm',true,reloadDeployments);
	}
	
	//根据条件查询
	function deploymentsSearch() {
		setGridSearchParams('deployments_list','deploymentsSearchForm',false,reloadDeployments);
	}
	
	function onDblClickDeploymentsRow(rowIndex, rowData) {
		createFromWindow("查看资源", "processdef.do?showSourceDeployments&deploymentId=" + rowData.id,
					null, function(data) {
						reloadDeployments();
					},false);
	}
	
</script>
<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		<@eu.datagrid id="deployments_list" toolbar="#deploymentslist_search"
		idField="id" url="processdef.do?listDeployments"
		rownumbers="true" onDblClickRow="onDblClickDeploymentsRow(rowIndex,
		rowData)" item="com.xdtech.oa.bpm.vo.DeploymentsItem"/>

		<div id="deploymentslist_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="deploymentsSearchForm">
					<!-- 防止form表单里只有一个text元素时候，按enter键自动提交问题 -->
					<input style="display:none" />
					<table>
						<tr>
						<td class="tbLabel">名称：</td>
							<td><input class="easyui-validatebox textbox" name="name" style="width: 150px" />
						</td>
						<td rowspan="2">
							<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="deploymentsSearch()"/>
 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearDeploymentsSearch()"/>
					 	</td>
						</tr>
					</table>
				</form>

			</div>
			<div id="deployments_toolbar" style="height: auto">
				<@eu.linkbutton showName="新增" shiro="bmp:deployments:add"
				iconCls="icon-add" onclick="addDeployments()"/> 
				<@eu.linkbutton
				showName="删除" shiro="bmp:deployments:delete" iconCls="icon-remove"
				onclick="deleteDeployments()"/> 
<!-- 				<eu.linkbutton showName="查看资源" -->
<!-- 				shiro="bmp:deployments:showsource" iconCls="icon-edit" -->
<!-- 				onclick="showSourceDeployments()"/>  -->
				<@eu.linkbutton showName="刷新"
				shiro="bmp:deployments:refresh" iconCls="icon-reload"
				onclick="reloadDeployments()"/></div>
		</div>
	</div>
</div>